<template>
    <div>
      <app-head :title="title"></app-head>
      <div class="content">
            <h1 class="title">{{datas.title}}</h1>
        <div class="flex_b" style="margin-top: 8px">
            <p >{{datas.datetime}}</p>
            <p >{{datas.depart}} {{datas.name}}</p>
        </div>
        <div class="text">
          {{datas.describe}}
        </div>
        <div class="atta">
          附件
          <div style="margin-top: 4px">
            {{datas.flie}}
          </div>
        </div>
        <div class="record">
          <span>阅读 {{datas.readNum}}</span>
          <span>赞 {{datas.proveNum}}</span>
        </div>
        <!--留言板-->

      </div>
      <div class="word">
          <p class="tit flex_b">
            <span style="margin-bottom: 10px">精选留言</span>
            <router-link :to="{path:'/comment',query:{id:this.$route.query.id}}">
              <span style="color: #576B95">写留言</span>
            </router-link>
          </p>
        <div class="que_c ">
          <div class="que" v-for="(item,index) in messages">
            <dl class="img_d"><img :src="item.headImg" alt=""></dl>
            <dl style="margin-left: 12px;text-align: left">

              <dt class="name">{{item.datetime}}</dt>
              <dt class="con">{{item.content}}</dt>
              <dt class="data">{{item.outTime}}</dt>
              <div class="res" v-if="leaveWordMangeLen">
                <dl>管理员回复</dl>
                <p>{{item.leaveWordMange[0].content}}</p>
                <span>{{item.leaveWordMange[0].outTime}}</span>
              </div>
            </dl>
            <div class="line" v-if="index!=5"></div>

          </div>
          <p class="more">以上留言经筛选后显示</p>
        </div>
      </div>
    </div>
</template>

<script>
  import AppHead from '@/components/Head'
    export default {
        name: "Article",

        components:{
          AppHead
        },
        data () {
          return {
            title: '文章',
            datas:{},
            messages:[],
            leaveWordMangeLen:true
          }
        },
  mounted:function () {
    this.init()
  },
      methods:{
        init:function () {
          var that =this
          this.$http({
            method: 'get',
            url: '/article/article',
            // params:{
            //   id:that.$route.query.id
            // }
          }).then(function (res) {

            that.datas = res.data.datas[0]
            console.log(that.datas)
          }).catch(function (error) {

          })

          //留言板
          this.$http({
            method: 'get',
            url: '/article/leaveWord',
            // params:{
            //   id:that.$route.query.id
            // }
          }).then(function (res) {

            that.messages = res.data.datas
            if(!that.messages[0].leaveWordMange[0].content){
              that.leaveWordMangeLen = false
            }else{


            }

          }).catch(function (error) {

          })



        },
      }
    }
</script>

<style scoped lang="less">

  .content{

    padding-bottom: 30px;
    background: #fff;
  }
  .title{
    color: #333;font-size: 22px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: box;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    height: initial;
    -webkit-box-orient: vertical;
    white-space: initial;font-weight:400;text-align: left;line-height:30px;
  }
  .flex_b{
    justify-content: space-between;
  }
  .flex_b p{
    font-size:13px;
    color: #999;
    margin: 0;
    opacity: .7;
  }
  .text{
    text-indent: 2em;
    font-size:16px;
    line-height:27px;
    text-align: left;color: #333333;
    margin-top: 16px;
    opacity: .7;
  }
  .atta{
    border:1px solid #eee;
    padding: 8px 16px;
    text-align: left;
    margin: 16px 0;
    color: #777;
    div{
      font-size: 13px;color: #0076FF;
    }
  }
  .record{
    text-align: left;
  }
  .record span{
    font-size: 13px;
    color: #999999;
  }
  .word{
    margin-top: 25px;
    padding: 0 16px;
    background: #f4f4f4;
    font-size: 15px;
    color: #999;

  }
  .more{
    height:21px;
    font-size:15px;
    color: #ccc;
    text-align: center;
    padding: 16px 0;
  }
  .que{
    display:-webkit-box;
    display:-ms-flexbox;
    display:-webkit-flex;
    display:flex;
    position: relative;
    .img_d{
      width: 34px;
      height: 34px;
      img{
        width: 100%;
        height: 100%;
      }
    }
    .name{
      font-size: 15px;
      color: #666;
    }
    .con{
    color: #444444;
      font-size:16px;
      line-height: 22px;
      margin: 4px 0;
    }
    .data{
      font-size: 12px;
      color: #999;
    }
  }
  .line{
    height:1px;
    width: 327px;
    background:rgba(238,238,238,1);
    position: absolute;
    bottom: 0;
  }
  .que_c{

  }
  .res{
    dl{
      margin: 8px 0;
      border-left: 2px solid #5CB31B;
     padding-left: 4px;font-size: 15px;color: #666;
    }
    p{
      font-size: 16px;
      color: #444444;
      margin-bottom: 4px;
    }
    span{
      color: #999999;font-size: 12px;
    }
  }
</style>
